/**
 * 
 */
package simulator;

import java.util.ArrayList;
import java.util.List;

import gates.And;
import gates.Or;
import gates.Not;

/**
 * @author denis
 * 
 */
public class FaultSimulator {
	public void initialize() {

	}

	public boolean runSimulation(boolean in1, boolean in2, int defect) {
		And and = new And(in1, in2, defect);
		Not not = new Not(and.getOutput(), and.getDefect());
		return not.getOutput();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
//		FaultSimulator fs = new FaultSimulator();
//		boolean before = fs.runSimulation(true, true, 0);
//		fs.runSimulation(true, false, 0);
//		boolean after = fs.runSimulation(true, true, 8);
//		System.out.println(before + " : " + after);
		boolean[][] inputs = { { true, true }, { true, false },
				{ false, true }, { false, false } };
		int defect = 8;

		for (boolean[] inputCouple : inputs) {
			for (boolean[] beforeRunInputs : inputs) {
				System.out.println("Before run inputs: " + beforeRunInputs[0]
						+ " : " + beforeRunInputs[1]);
				System.out.println("This run inputs: " + inputCouple[0] + " : "
						+ inputCouple[1]);
				FaultSimulator fs = new FaultSimulator();
				
				boolean beforeOutput = fs.runSimulation(inputCouple[0], inputCouple[1], 0);
				fs.runSimulation(beforeRunInputs[0], beforeRunInputs[1], 0);
				boolean output = fs.runSimulation(inputCouple[0],
						inputCouple[1], defect);
				System.out.println("Defective result: " + output
						+ ";\nClean result: " + beforeOutput
						+ (output != beforeOutput ? "<-------\n" : "\n"));
			}
		}
	}

}
